<%@page import="com.xhd.vo.Fruits"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>商品详情</title>

<meta name="viewport" content="width=device-width, initial-scale=1"> 
<style type="text/css">
			*{
				margin: 0;
				padding: 0;
			}
		.top{
		width:100%;
		height:80px;
		background-color:gray;
		padding-bottom: 10px;
		}
		.top1{
			width:40%;
			height:80px;
			float:left;	
			padding-bottom: 10px;
		}
		.top2{
			width:20%;
			height:80px;
			float:left;	
			padding-bottom: 10px;
		}
		.top3{
			width:20%;
			height:80px;
			float:left;	
			padding-bottom: 10px;
		}
			.a1 ul{
				list-style: none;
				margin-top: 30px;
			}
			.a1{
				width: 400px;
				height: 480px;/* 计算好的,大图是400px,小图是50px,大图和小图上下间隔30px; */
			}
			.a1 p{
				border: 1px solid #ccc;
			}
			.a1 ul li{
				float: left;
				margin-left: 64px;
			}
			.a1 ul li img{
				cursor: pointer;/* 鼠标放小图片上变成手的形状 */
			}
		</style>
		<script type="text/javascript">
			window.onload = function(){
				var ul = document.getElementById("smUl"); //先得到ul的引用对象
				var imgs = ul.getElementsByTagName("img"); //再通过ul的引用对象得到img的引用对象
				for (var i = 0; i < imgs.length; i++) {//遍历注册事件
					imgs[i].onmouseover = function(){
						var bigImg = document.getElementById("detail");
						bigImg.src = this.getAttribute("data");
					}
				}
			}
		</script>



<link rel="stylesheet" href="css/common.css">
<link rel="stylesheet" href="css/detail.css">
<title>Insert title here</title>
</head>
<body>
<%
//解决中文乱码
response.setContentType("text/html;charset=utf-8");
//请求解决乱码
request.setCharacterEncoding("utf-8");
//响应解决乱码
response.setCharacterEncoding("utf-8");
	String name = (String)request.getParameter("name");
	String price = (String)request.getParameter("price");
	String describe = (String)request.getParameter("describe");
	String picture = (String)request.getParameter("picture");
	String stock = (String)request.getParameter("stock");
	Fruits fruit = new Fruits(name,describe,picture,price,"待售",stock);
	//System.out.println(fruit.getFruit_name());
	//System.out.println(fruit.getFruit_describe());
	//System.out.println(fruit.getFruit_picture());
	//System.out.println(fruit.getFruit_price());
	if(fruit.getFruit_name()==null||fruit.getFruit_describe()==null||fruit.getFruit_picture()==null||fruit.getFruit_price()==null||fruit.getFruit_stock()==null){
%>
您未选择商品<a href="HistoryMessage.jsp">请返回</a>\
<%}else{ %>
<div id="all">
	<div class="top">
		<div class="top2">
		<a href="HistoryMessage.jsp"><h1 align="center">返回全部商品</h1></a>
		</div>
	</div>
</div>
			<div style="clear: both;"></div>
			<div id="content">
					<div id="container" class="a1">
					<%int left = 0;
					  int right = fruit.getFruit_picture().indexOf("@"); 
					  if(right==-1){
						  right=fruit.getFruit_picture().length();
					  }
					  String imagepath = fruit.getFruit_picture().substring(left,right);
					%>
						<p><img class="big" src="./upload/<%=imagepath %>" id = "detail"></p>
						<div class="a11">
							<ul id = "smUl">	
								<%
								int i =1;
								left = 0;
								right = fruit.getFruit_picture().indexOf("@");
								while(right!=-1) {
									imagepath = fruit.getFruit_picture().substring(left,right);
									//System.out.println("1:"+imagepath);
									%>
									<li><img  src="./upload/<%=imagepath %>" data="./upload/<%=imagepath%>"></li>
									<%
									left=right+1;
									right=fruit.getFruit_picture().indexOf("@",right+1);
									}
									imagepath = fruit.getFruit_picture().substring(left,fruit.getFruit_picture().length());
									//System.out.println("2:"+imagepath);
									%>
									<li><img  src="./upload/<%=imagepath %>" data="./upload/<%=imagepath%>"></li>
							</ul>
						</div>
					</div>									
				<div class="a2">
					<h2><%=fruit.getFruit_name() %></h2>
					<div class="a21">
						<div class="a211">
							<span class="color">售价</span>
							<span class="prices">￥<%=fruit.getFruit_price() %></span>
							<%-- <span class="shic">市场价<span class="prices2">￥338</span></span>--%>
							<%-- <span class="yis">已售6264件</span>--%>
						</div>
						<div class="a22">
							<p></p>
							<span class="color">产品描述</span>
							<span class="neir"><textarea  style='resize:none'  border-style="none"  background="transparent" readonly="readonly" rows="5" cols="30"><%=fruit.getFruit_describe() %></textarea></span>
							<p></p>
							<span class="color">包装</span>
							<span class="neir">均使用保鲜盒包装运送，部分冷冻包装</span>
							<p></p>
							<span class="color">备注</span>
							<span class="neir">品牌:小虎队水果店</span>
						</div>
						<div class="a23">
							<p></p>
							<span class="color">商品在售状态</span>
							<p>在售,剩余<%=fruit.getFruit_stock() %>公斤</p>
							<span class="color">交易点至</span>
							<p>杭州</p>
							<span class="color">说明</span>
							<p>偏远地区暂不线下交易</p>
						</div>
						<div class="a24">
							<span class="color">选择</span>
							<p></p>
							<span class="bang">2磅</span>
							<span class="bang">3磅</span>
							<span class="bang">4磅</span>
						</div>

					</div>
				</div>
			</div>
			<div style="clear: both;"></div>
			<div class="bottom">
				<h2 align="center">为什么要吃水果呢？</h2>
				<p align="center">吃水果可以帮助我们美容养颜、减缓衰老、预防疾病、降血压、减肥瘦身哦。</p>
			</div>
		</div>
<%} %>

</body>
</html>